home *** CD-ROM | disk | FTP | other *** search
/ Hyper Stacks 1994 May / Hyper Stacks (Pacific HiTech)(1994)[Mac].iso / HyperTalk / AppleTalk Toolkit v.2.5 / ATP / ATPOpen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-02-22  |  3.2 KB  |  109 lines  |  [TEXT/MPS ]

  1. /*******************************************************************\
  2. *    file:         AtpOpen.c                                            *
  3. *    version:    1.06ß                                                 *
  4. *                                                                     *
  5. * This command checks for network availability, connects us to        *
  6. * a socket and allocates the appletalk buffers.    If server requested,*
  7. * opens a listening socket.                                            *
  8. *                                                                    *
  9. * -----------------------------------------------------------------    *
  10. * By:    Donald Koscheka, Greg Kimberly                                *
  11. * Date:    21-Sept-87                                                    *
  12. * ©    Copyright 1987, Apple Computer, Inc.                            *
  13. *    All Rights Reserved                                                *
  14. *                                                                    *
  15. * -----------------------------------------------------------------    *
  16. *                        Modification History                        *
  17. * -----------------------------------------------------------------    *
  18. *  Date           | By    |                     Description                    *
  19. * -----------------------------------------------------------------    *
  20. * 21-Sep-87    | GK    | file created                                    *
  21. *  5-Nov-87    | DK    | added return result                            *
  22. *            |        | added open as client/server/both                *
  23. * 14-Jan-87    | DK    | modified to reflect generalized control struct*
  24. *            |        | (saves address off in global container)        *
  25. * 22-Feb-88 | DK    | Move all locked handles high                    *
  26. * -----------------------------------------------------------------    *
  27. \*******************************************************************/
  28.  
  29. /*******************************************************************\
  30.                             Build Sequence
  31.  
  32. C -q2 -g -o "{hpo}"ATPOpen.c.o "{atp}"ATPOpen.c
  33.     link  -sn Main=ATPOpen -sn STDIO=ATPOpen ∂
  34.          -sn INTENV=ATPOpen -rt XCMD=303 ∂
  35.          -m ATPOPEN ∂
  36.          "{hpo}"ATPOpen.c.o  "{hpo}"atalkxcmd.c.o "{hpo}"xcmdutils.c.o ∂
  37.          "{CLibraries}"CInterface.o ∂
  38.          "{Libraries}"Interface.o ∂
  39.          -o "{hp}"HyperPeople
  40.          
  41. \*******************************************************************/
  42.  
  43.  
  44. #include <Types.h>
  45. #include <Memory.h>
  46. #include <Resources.h>
  47. #include <OSUtils.h>
  48. #include <appleTalk.h>
  49. #include <HyperXCmd.h>
  50. #include <atalkXCMD.h>
  51. #include <XCMDUtils.h>
  52.  
  53.  
  54. pascal void ATPOpen( paramPtr )
  55.     XCmdBlockPtr    paramPtr;
  56. /**********************************
  57. * Open up access to the network via the
  58. * ATP layer of appletalk. Node may be 
  59. * CLIENT, SERVER or BOTH (neither specified)
  60. *
  61. * In:
  62. *    params[0]    char    *NodeType
  63. *
  64. * Defaults : CLIENT/SERVER
  65. *
  66. * Out: Error Result is returned to hypercard
  67. **********************************/
  68. {
  69.     ATPBlock     *atp = nil;
  70.     Handle         tempH,name, zNameH,zBuffHandle;
  71.     char         s[32];
  72.     Str31         **buffHandle;
  73.     short        error = noErr;
  74.     short        type = SERVER+CLIENT;
  75.  
  76.     /*** Don't reopen if atp is already allocated ***/
  77.     atp = (ATPBlock *)RetrieveHandle( paramPtr, GLOBALATPDATA );
  78.     if( !atp ){ 
  79.         if( paramPtr->params[0] ){
  80.             HLock( paramPtr->params[0] );
  81.             s[0]='C';s[1]='L';s[2]='I';s[3]='E';s[4]='N';s[5]='T';s[6]='\0';
  82.     
  83.             if ( strCMP( s, *(paramPtr->params[0])) == 0 )
  84.                 type = CLIENT;
  85.             else{
  86.                 s[0]='S';s[1]='E';s[2]='R';s[3]='V';s[4]='E';s[5]='R';s[6]='\0';
  87.                 if( strCMP( s, *(paramPtr->params[0])) == 0)
  88.                     type = SERVER;
  89.             }    
  90.             HUnlock( paramPtr->params[0] );
  91.         }
  92.         
  93.         atp = ATPInit( 10, type );
  94.         
  95.         if( atp ){
  96.             SaveHandle( paramPtr, GLOBALATPDATA, atp );
  97.             SaveHandle( paramPtr, GLOBALSKTDATA, atp->ServerAddr );
  98.         }
  99.         else
  100.             error = DEFAULT_ERROR;
  101.  
  102.     }    
  103.  
  104.     paramPtr->returnValue = ErrorReturn( error );
  105.     
  106. }
  107.  
  108.  
  109.